<?

/**
* Use $_SESSION["GDate"] if you are using custom date
* or just use the system date 
*
* $today_date = $_SESSION["GDate"];
* $today_date = date("d-m-Y");
*
*/
$today_date		  = date("d-m-Y");

$srcDbHdr    = "IMPORT_HDR";
$srcDbDtl    = "IMPORT_DTL";
$srcDbHdrLog = "LOG_IMPORT_HDR";

$UID     = unserialize($_SESSION["serUID"]);
$userId  = $UID->getUID();

$Db = new oracleDb;
$Db->init($_SESSION["ORCL"], 
           $_SESSION["OPASS"],
           $_SESSION["SID"],
           _NO_COMMENT);

if($Db->connect()){
	
	/** 
	* Delete the previous entry
	*
	*/
	$CHandlers->dbEntDelete($Db,
            	            $_SESSION["jid"],
            	            $srcDbHdr);
	            
  $CHandlers->dbEntDelete($Db,
            	            $_SESSION["jid"],
            	            $srcDbDtl);
	
  /**
  * We don't build up any jobId anymore since this is
  * a modify mode. Also we already have the previous
  * jobId in $_SESSION
  *
  */
  $jobId = $_SESSION["jid"];
  
  $hdrDate = "TO_DATE('".$_POST["trDateEnt"]."' , 'dd-mm-YYYY')";
    
  $CFetchers->fetchHdrNo($Db,
                         $_POST["trDateEnt"],
                         $srcDbHdr,
                         $hdrNo);
            
  /**
  * Insert Log
  *
  */
  $CHandlers->insToDbLog($Db,
                         $today_date,
                         $jobId,
                         $userId,
                         $_SERVER["REMOTE_ADDR"],
                         _ENTRY_MODE,
                         $srcDbHdrLog);
                               
	$Db->commit();
	
	if($Db->getStatus() == true){
	
	  $Misc->usrMsg("Modify Complete");
	}else{
	  
	  $Misc->usrDieJs("Modify Process Interupted");
	}
	
	$Db->dc();
	
	/**
	* Pending...
	* I'm not sure if this 
	* reset procedure off
	* causes buggy 
	*
	*	$restore  = 0;
	* $uprun    = 0;
	* $dataup   = 0;
	*
	*/
	//jumpTo(2,"../".$_SESSION["source_caller"]);
	
}else{
	
	$Misc->usrDieJs("Db connection failed");
}

?> 